@include('admin.layout.bone_header')

<div class="layui-form layui-form-pane search">

    <div class="layui-form-item">


        <label class="layui-form-label">会员ID</label>
        <div class="layui-input-inline">
            <input type="text" id="user_id" autocomplete="off" placeholder="请输入会员ID" class="layui-input">
        </div>

        <label class="layui-form-label">开始时间</label>
        <div class="layui-input-inline">
            <input type="text" class="layui-input" autocomplete="off" id="start_time" placeholder="开始时间" lay-key="1">
        </div>

        <label class="layui-form-label">结束时间</label>
        <div class="layui-input-inline">
            <input type="text" class="layui-input" autocomplete="off" id="end_time" placeholder="结束时间" lay-key="2">
        </div>


        <button class="layui-btn" data-type="reload">搜索</button>
    </div>
</div>


<table class="layui-hide" id="think-table" lay-filter="think-table"></table>

<script type="text/html" id="barDemo">
    @{{# if(d['status'] == 0){ }}
    <a class="layui-btn layui-btn-xs" lay-event="edit">审核</a>
    @{{# } }}
</script>

<script>

    layui.use(['table','laydate'], function () {
        let table = layui.table,
            laydate = layui.laydate;


        laydate.render({
            elem: '#start_time'
        });

        laydate.render({
            elem: '#end_time'
        });
        UI.getPageTable(table, "{{route('admin.widthwals.widthwals')}}", [
            {field: 'withdrawal_id', title: 'ID', width: 80, sort: true, fixed: 'left'}
            , {field: 'user_id', title: ' 用户ID'}
            , {field: 'money', title: ' 金额',templet:function (d){
                return parseFloat(d['nums'])+parseFloat(d['fee'])
                }}
            , {field: 'nums', title: ' 打款金额'}
            , {field: 'fee', title: ' 手续费'}
            , {field: '银行卡信息',width: 240, title: ' 银行卡信息',templet:function (d){
                    let json_data = JSON.parse(d['card_json_data']);
                    return json_data['name']+'---'+json_data['card_no']+'---'+json_data['card_kai']
            }}
            , {field: 'sorts', title: ' 排序',templet:function (d){
                    let arr = ['待审核','通过','拒绝']
                    return arr[d['status']]
                }}
            , {field: 'created-at',width: 180, title: ' 时间',templet:function (d){
                return Utils.paraseTime(d['created_at'])
                }}
            ,{fixed: 'right',title:'操作', align:'center', toolbar: '#barDemo'}
        ]);

        table.on('tool(think-table)', function (obj) {
            let data = obj.data;
            if(obj.event === 'edit'){
                UI.openLayer("{{route('admin.widthwals.edit')}}?withdrawal_id="+data['withdrawal_id']);
            }
        });
        let $ = layui.$, active = {
            addImages:function (){
            },
            reload:function (){
                let user_id = $('#user_id');
                let start_time = $('#start_time');
                let end_time = $('#end_time');
                //执行重载
                table.reload('think-table', {
                    page: {
                        curr: 1 //重新从第 1 页开始
                    }
                    ,where: {
                        'user_id':user_id.val(),
                        'start_time':start_time.val(),
                        'end_time':end_time.val(),
                    }
                });
            }
        };
        $('.layui-btn-container .layui-btn').on('click', function () {
            let type = $(this).data('type');
            active[type] ? active[type].call(this) : '';
        });

        $('.search .layui-btn').on('click', function () {
            let type = $(this).data('type');
            active[type] ? active[type].call(this) : '';
        });

    })


</script>


@include('admin.layout.bone_footer')
